#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <aclconio.h>
#include <define.h>
#include <transact.h>
#include <tran.h>
#include <gds.h>
#include <sizes.h>
#include "ConfProto.h"
#include "tblutil.h"
#include <\SOFTPAY\Ver30\source\include\sizes.h>
#include <\SOFTPAY\Ver30\HostSrc\citisrc\citiids.h>
#include <\SOFTPAY\Ver30\HostSrc\cpacsrc\cpacids.h>
#include <confio.h>

#include <\SOFTPAY\Ver30\source\include\PCL.h>



static void *storeFromStruct;

static int recordNum;
void registerPCL(void *ptr)
{
	 storeFromStruct = ptr;
}

void *dealWithAddressBoundary(void*address);
int	inLoadPCLRecFromStruct (int inRecNumber, void *vdStruct)
{
	int inRet;
	char* tmp = (char*)vdStruct;

	registerPCL(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inLoadConfRec(PCL_FILENAME, SIZE_PCL_REC, inRecNumber, vdStruct);

	recordNum = inRecNumber;
	return inRet;
}

void vdRestorePCLRecFromStruct(void *vdStruct)
{
	registerPCL(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	memcpy((char *) pvdGetPCLRec(), vdStruct, SIZE_PCL_REC);

}

void vdCopyPCLRecFromStruct(void *vdStruct)
{
	registerPCL(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
		memcpy(vdStruct, (char *) pvdGetPCLRec(), SIZE_PCL_REC);

}

int	inSavePCLRecFromStruct (int inRecNumber,  void *vdStruct)
{
	int inRet;

	registerPCL(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(PCL_FILENAME, SIZE_PCL_REC, inRecNumber, (char *) vdStruct);

	return inRet;
}

int	inUpdatePCLRecFromStruct (void *vdStruct)
{
	int inRet;

	registerPCL(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(PCL_FILENAME, SIZE_PCL_REC, recordNum, (char *) vdStruct);

	return inRet;
}

short shGetImamUCLIndexFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return shGetImamUCLIndex();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->shImamUCLIndex;
}

void vdSetImamUCLIndexFromStruct(short shImamUCLIndex, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamUCLIndex(shImamUCLIndex);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->shImamUCLIndex = shImamUCLIndex;
}

short inGetImamUCLCommFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetImamUCLComm();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->inImamUCLComm;
}

void vdSetImamUCLCommFromStruct(short inImamUCLComm, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamUCLComm(inImamUCLComm);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->inImamUCLComm = inImamUCLComm;
}

char* szGetImamPriHostIPFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamPriHostIP();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamPriHostIP;
}

void vdSetImamPriHostIPFromStruct(const char* szImamPriHostIP, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamPriHostIP(szImamPriHostIP);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamPriHostIP, szImamPriHostIP, sizeof(((PCL_REC*)NULL)->szImamPriHostIP)-1);
}

short inGetImamPriPortFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetImamPriPort();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->inImamPriPort;
}

void vdSetImamPriPortFromStruct(short inImamPriPort, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamPriPort(inImamPriPort);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->inImamPriPort = inImamPriPort;
}

char* szGetImamSecHostIPFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamSecHostIP();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamSecHostIP;
}

void vdSetImamSecHostIPFromStruct(const char* szImamSecHostIP, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamSecHostIP(szImamSecHostIP);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamSecHostIP, szImamSecHostIP, sizeof(((PCL_REC*)NULL)->szImamSecHostIP)-1);
}

short inGetImamSecPortFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetImamSecPort();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->inImamSecPort;
}

void vdSetImamSecPortFromStruct(short inImamSecPort, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamSecPort(inImamSecPort);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->inImamSecPort = inImamSecPort;
}

char* szGetImamLocalIPFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamLocalIP();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamLocalIP;
}

void vdSetImamLocalIPFromStruct(const char* szImamLocalIP, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamLocalIP(szImamLocalIP);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamLocalIP, szImamLocalIP, sizeof(((PCL_REC*)NULL)->szImamLocalIP)-1);
}

char* szGetImamSubnetFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamSubnet();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamSubnet;
}

void vdSetImamSubnetFromStruct(const char* szImamSubnet, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamSubnet(szImamSubnet);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamSubnet, szImamSubnet, sizeof(((PCL_REC*)NULL)->szImamSubnet)-1);
}

char* szGetImamGatewayFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamGateway();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamGateway;
}

void vdSetImamGatewayFromStruct(const char* szImamGateway, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamGateway(szImamGateway);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamGateway, szImamGateway, sizeof(((PCL_REC*)NULL)->szImamGateway)-1);
}

short inGetImamPPPAuthFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetImamPPPAuth();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->inImamPPPAuth;
}

void vdSetImamPPPAuthFromStruct(short inImamPPPAuth, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamPPPAuth(inImamPPPAuth);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->inImamPPPAuth = inImamPPPAuth;
}

short inGetImamIdleConnectTimeFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetImamIdleConnectTime();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->inImamIdleConnectTime;
}

void vdSetImamIdleConnectTimeFromStruct(short inImamIdleConnectTime, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamIdleConnectTime(inImamIdleConnectTime);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->inImamIdleConnectTime = inImamIdleConnectTime;
}

short inGetImamKeepAliveTimerFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetImamKeepAliveTimer();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->inImamKeepAliveTimer;
}

void vdSetImamKeepAliveTimerFromStruct(short inImamKeepAliveTimer, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamKeepAliveTimer(inImamKeepAliveTimer);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->inImamKeepAliveTimer = inImamKeepAliveTimer;
}

short inGetImamFirstSocketTimeOutFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetImamFirstSocketTimeOut();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->inImamFirstSocketTimeOut;
}

void vdSetImamFirstSocketTimeOutFromStruct(short inImamFirstSocketTimeOut, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamFirstSocketTimeOut(inImamFirstSocketTimeOut);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->inImamFirstSocketTimeOut = inImamFirstSocketTimeOut;
}

short inGetImamEncryptTypeFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetImamEncryptType();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->inImamEncryptType;
}

void vdSetImamEncryptTypeFromStruct(short inImamEncryptType, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamEncryptType(inImamEncryptType);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->inImamEncryptType = inImamEncryptType;
}

char* szGetImamUCLUserNameFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamUCLUserName();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamUCLUserName;
}

void vdSetImamUCLUserNameFromStruct(const char* szImamUCLUserName, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamUCLUserName(szImamUCLUserName);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamUCLUserName, szImamUCLUserName, sizeof(((PCL_REC*)NULL)->szImamUCLUserName)-1);
}

char* szGetImamUCLPasswordFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamUCLPassword();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamUCLPassword;
}

void vdSetImamUCLPasswordFromStruct(const char* szImamUCLPassword, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamUCLPassword(szImamUCLPassword);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamUCLPassword, szImamUCLPassword, sizeof(((PCL_REC*)NULL)->szImamUCLPassword)-1);
}

char* szGetImamGPRSDialNoFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamGPRSDialNo();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamGPRSDialNo;
}

void vdSetImamGPRSDialNoFromStruct(const char* szImamGPRSDialNo, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamGPRSDialNo(szImamGPRSDialNo);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamGPRSDialNo, szImamGPRSDialNo, sizeof(((PCL_REC*)NULL)->szImamGPRSDialNo)-1);
}

char* szGetImamGPRSAPNFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamGPRSAPN();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamGPRSAPN;
}

void vdSetImamGPRSAPNFromStruct(const char* szImamGPRSAPN, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamGPRSAPN(szImamGPRSAPN);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamGPRSAPN, szImamGPRSAPN, sizeof(((PCL_REC*)NULL)->szImamGPRSAPN)-1);
}

short inGetImamWiFiChannelFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetImamWiFiChannel();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->inImamWiFiChannel;
}

void vdSetImamWiFiChannelFromStruct(short inImamWiFiChannel, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamWiFiChannel(inImamWiFiChannel);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->inImamWiFiChannel = inImamWiFiChannel;
}

char* szGetImamWiFiSysIDFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamWiFiSysID();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamWiFiSysID;
}

void vdSetImamWiFiSysIDFromStruct(const char* szImamWiFiSysID, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamWiFiSysID(szImamWiFiSysID);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamWiFiSysID, szImamWiFiSysID, sizeof(((PCL_REC*)NULL)->szImamWiFiSysID)-1);
}

short inGetImamWiFiWEPModeFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetImamWiFiWEPMode();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->inImamWiFiWEPMode;
}

void vdSetImamWiFiWEPModeFromStruct(short inImamWiFiWEPMode, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamWiFiWEPMode(inImamWiFiWEPMode);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->inImamWiFiWEPMode = inImamWiFiWEPMode;
}

char* szGetImamWiFiWEPKeyValueFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetImamWiFiWEPKeyValue();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->szImamWiFiWEPKeyValue;
}

void vdSetImamWiFiWEPKeyValueFromStruct(const char* szImamWiFiWEPKeyValue, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamWiFiWEPKeyValue(szImamWiFiWEPKeyValue);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCL_REC*)vdStruct)->szImamWiFiWEPKeyValue, szImamWiFiWEPKeyValue, sizeof(((PCL_REC*)NULL)->szImamWiFiWEPKeyValue)-1);
}

VS_BOOL fGetImamPCLPADBIT1FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetImamPCLPADBIT1();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->fImamPCLPADBIT1;
}

void vdSetImamPCLPADBIT1FromStruct(VS_BOOL fImamPCLPADBIT1, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamPCLPADBIT1(fImamPCLPADBIT1);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->fImamPCLPADBIT1 = fImamPCLPADBIT1;
}

VS_BOOL fGetImamPCLPADBIT2FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetImamPCLPADBIT2();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->fImamPCLPADBIT2;
}

void vdSetImamPCLPADBIT2FromStruct(VS_BOOL fImamPCLPADBIT2, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamPCLPADBIT2(fImamPCLPADBIT2);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->fImamPCLPADBIT2 = fImamPCLPADBIT2;
}

VS_BOOL fGetImamPCLPADBIT3FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetImamPCLPADBIT3();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCL_REC*)vdStruct)->fImamPCLPADBIT3;
}

void vdSetImamPCLPADBIT3FromStruct(VS_BOOL fImamPCLPADBIT3, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetImamPCLPADBIT3(fImamPCLPADBIT3);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCL_REC*)vdStruct)->fImamPCLPADBIT3 = fImamPCLPADBIT3;
}

